package com.aglow.bluetoothspeaker.presenter.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.aglow.bluetoothspeaker.model.event.HomeKeyEvent;

import org.greenrobot.eventbus.EventBus;

public class HomeKeyReceiver extends BroadcastReceiver {
    final String SYSTEM_DIALOG_REASON_KEY = "reason";

    final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";

    final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
            String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
            if (reason!=null){
                if (reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)){
                    //释放蓝牙资源
                    EventBus.getDefault().post(new HomeKeyEvent());

                }
            }

        }
    }
}
